const pkg = require('./package')

module.exports = {
  //mode: 'spa',

  // //缓存配置
  // cache: true,
  // cache: {
  //   max: 1000,//缓存组件的最大数目，当第 1001 个组件被添加至缓存中时， 第一个被缓存的组件会从缓存中移除。
  //   maxAge: 900000//缓存时间，单位毫秒, 默认是 15 分钟。
  // },

  /*
  ** Headers of the page
  */
  head: {
    title: pkg.name,
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: '我的'+pkg.description },
    ],
    script: [
      { src: 'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js' },
      { src: 'https://cdn.staticfile.org/twitter-bootstrap/4.1.0/js/bootstrap.min.js' }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
      { rel: 'stylesheet', href: 'https://cdn.staticfile.org/twitter-bootstrap/4.1.0/css/bootstrap.min.css' }
    ]
  },

  /*
  ** Customize the progress-bar color
  */
  loading: { color: '#218ff2' },

  /*
  ** Global CSS
  */
  css: [
  ],

  /*
  ** Plugins to load before mounting the App
  */
  plugins: [
    { src: "~plugins/axios.js", ssr: true },
  ],

  /*
  ** Nuxt.js modules
  */
  modules: [
    // Doc: https://github.com/nuxt-community/axios-module#usage
    '@nuxtjs/axios',
    '@nuxtjs/proxy'
  ],

  proxy: [
    [
      '/fangwei/',//拦截目录
      {
        target: 'http://www.china3-15.com', // 代理api主机
        pathRewrite: { '^/fangwei/' : '' }//将拦截目录置空
      }
    ],
    [
      '/juejin1/',
      {
        target: 'http://short-msg-ms.juejin.im',
        pathRewrite: { '^/juejin1/' : ''}
      }
    ],
    [
      '/juejin2/',
      {
        target: 'http://xiaoce-timeline-api-ms.juejin.im',
        pathRewrite: { '^/juejin2/' : ''}
      }
    ],
    [
      '/qqmusic/',
      {
        target: 'https://c.y.qq.com',
        pathRewrite: { '^/qqmusic/' : ''}
      }
    ],


  ],

  /*
  ** Axios module configuration
  */
  axios: {
    // See https://github.com/nuxt-community/axios-module#options
    retry: { retries: 3 },
    //开发模式下开启debug
    debug: process.env._ENV == "production" ? false : true,
    //设置不同环境的请求地址
    baseURL:
      process.env._ENV == "production"
        ? "http://localhost:3000"
        : "http://localhost:3000",
    withCredentials: true,
  },

  /*
  ** Build configuration
  */
  build: {
    /*
    ** You can extend webpack config here
    */
    extend(config, ctx) {

    }
  }
}
